﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Man adam = new Man(null, null, "Адам");
            Console.WriteLine(adam.Hello());
            Woman eva = new Woman(null, null, "Ева");
            Console.WriteLine(eva.Hello());
            Man vovan = new Man(adam, eva, "Вован");
            Console.WriteLine(vovan.Hello());
            Woman kain = new Woman(adam, eva, "Каин");
            Console.WriteLine(kain.Hello());
            Man enot = new Man(vovan, kain, "Енот");
            Console.WriteLine(enot.Hello());
            Man man = new Man(enot, null, null);
            man.GetRandomName();
            Console.WriteLine(man.Hello());
            Console.ReadLine();
        }
    }
    class Human
    {
        public List<Human> Children = new List<Human>();
        Man Father;
        Woman Mother;
        public string Firstname;
        public static string[] names = new string[] { "Виталий", "Виталий", "Виталий", "Виталий", "Виталий" };
        public Human(Man father , Woman mother, string name)
        {
            Father = father;
            Mother = mother;
            Firstname = name;
            //names[0] = "Виталий";
            //names[1] = "Никита";
            //names[2] = "Олег";
            //names[3] = "Илья";
            //names[4] = "Андрей";
            //names[5] = "Влада";
            //names[6] = "Маша";
            //names[7] = "Аня";
            //names[8] = "Даша";
            //names[9] = "Вика";
            if (father!= null && mother != null)
            {
                father.Children.Add(this);
                mother.Children.Add(this);
            }
            else
            {
                Children.Add(this);
            }
        }


        public virtual string Hello()
        {
            string result;
            result = String.Format("Привет! Меня зовут {0}. ", Firstname);
            if (Father == null)
            {
                result += " У меня нет отца.";
            }
            else
            {
                result += " Мой отец - " + Father.Firstname + ".";
            }

            if (Mother == null)
            {
                result += " У меня нет матери.";
            }
            else
            {
                result += " Моя мать - " + Mother.Firstname + ".";
            }
            if (Children.Count > 0)
            {
                result += " У меня " + Children.Count + " " + GetChildWord(Children.Count) + ": ";
                for (int i = 0; i < Children.Count; i++)
                {
                    if (i == Children.Count)
                    {
                        result += Children[i].Firstname;
                    }
                    else
                    {
                        result += Children[i].Firstname + ", ";
                    }
                }
                result += ".";


            }
            return result;
        }
        

        public string GetChildWord(int count)
        {
            switch (count)
            {
                case 1:
                    return "ребёнок";
                    break;
                case 2:
                case 3:
                case 4:
                    return "ребёнка";
                    break;
               default:
                   return "детей";
                    break;
            }
            return "";
        }


    }

    class Man : Human
    {
        string[] Car = new string[3];
        string LikeCar;
        public void GetRandomName()
        {
            Random rd = new Random();
            Firstname = names[Convert.ToInt32(rd.Next(0, 4))];
        }
        public Man(Man father, Woman mother, string name) : base(father, mother, name)
        {
            Car[0] = "Nissan";
            Car[1] = "Ford";
            Car[2] = "Opel";
            Random rd = new Random();
            LikeCar = Car[Convert.ToInt32(rd.Next(0, 2))];
        }
        public override string Hello()
        {
            return base.Hello() + " Я мужского пола. Моя любимая машина " + LikeCar;
        }
    }

    class Woman : Human
    {
        string[] Food = new string[3];
        string LikeFood;
        public void GetRandomName()
        {
            Random rd = new Random();
            Firstname = names[Convert.ToInt32(rd.Next(5, 9))];
        }
        public Woman(Man father, Woman mother, string name) : base(father, mother, name)
        {
            Random rd = new Random();
            Food[0] = "Макароны";
            Food[1] = "Греческий салат";
            Food[2] = "Отбивная";
            LikeFood = Food[Convert.ToInt32(rd.Next(0, 2))];
        }
        public override string Hello()
        {
            return base.Hello() + " Я женского пола. Мое любимое блюдо " + LikeFood;
        }
    }
 }
